/**   
 * @Title: FootballHemaiGetDetailCommunicater.java 
 * @Package com.esun.rabbit2.communicaters 
 * @Description: (通讯接口,业务标号10042) 
 * @author: Kuroky Chengxt@500wan.com   
 * @date: 2011-8-17 下午02:27:38  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.sportteryfootball;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.model.sportteryfootball.FootballHemaiDetailInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: FootballHemaiGetDetailCommunicater
 * @Description: (获取竞彩足球合买详细内容)
 * @author: Kuroky Chengxt@500wan.com
 * @date: 2011-8-17 下午02:27:38
 * 
 */
public class FootballHemaiGetDetailCommunicater extends ServerCommunicater {
	private String msgServer; // 服务器信息
	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	public boolean isGetDetailSucced(String lotId, String programId) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_HEMAI_DETIAL_FOOTBALL));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, lotId));
		list.add(mapItem(Key.KEY_PID, programId));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}
		return isSucceed;
	}

	public void updateHemaiDetailInfo() {
		// 比赛数目
		int gameCount = super.getListResult().size();
		FootballHemaiDetailInfo.getHemaiDetailInfo().setAddTime(super.getResult().get(Key.KEY_ADDTIME));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setAllCount(super.getResult().get(Key.KEY_ANUMBER));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setAllMoney(super.getResult().get(Key.KEY_ALLMONEY));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setBaodiMoney(super.getResult().get(Key.KEY_BAODIMONEY));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setBeishu(super.getResult().get(Key.KEY_BEISHU));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setEachMoney(super.getResult().get(Key.KEY_ONEMONEY));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setHitCount(super.getResult().get(Key.KEY_LOTTERYCOUNT));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setHitMoney(super.getResult().get(Key.KEY_LOTTERYMONERY));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setJindu(super.getResult().get(Key.KEY_RENQI));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setLeftCount(super.getResult().get(Key.KEY_LEFTNUMBER));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setGgtype(super.getResult().get(Key.KEY_GGTYPE));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setGgtypeName(super.getResult().get(Key.KEY_GGTYPENAME));
		if (super.getResult().get(Key.KEY_ISMANYUAN).equals(Config.NUM1)) {
			FootballHemaiDetailInfo.getHemaiDetailInfo().setState(Language.POPLOTTERYTIP_MANYUAN);
		} else {
			FootballHemaiDetailInfo.getHemaiDetailInfo().setState(Language.POPLOTTERYTIP_WEIMANYUAN);
		}
		FootballHemaiDetailInfo.getHemaiDetailInfo().setStrFaqiren(super.getResult().get(Key.KEY_USERNAME));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setTicheng(super.getResult().get(Key.KEY_BONUSRATIO));
		FootballHemaiDetailInfo.getHemaiDetailInfo().setIssuc(super.getResult().get(Key.KEY_ISSUC));

		String[] matchdate = new String[gameCount];
		String[] homesxname = new String[gameCount];
		String[] awaysxname = new String[gameCount];
		String[] rangqiu = new String[gameCount];
		String[] spf = new String[gameCount];
		String[] peilv = new String[gameCount];
		String[] isdanma = new String[gameCount];
		for (int i = 0; i < gameCount; i++) {
			matchdate[i] = super.getListResult().get(i).get(Key.KEY_MATCHNUM);
			homesxname[i] = super.getListResult().get(i).get(Key.KEY_HOMESXNAME);
			awaysxname[i] = super.getListResult().get(i).get(Key.KEY_AWAYSXNAME);
			rangqiu[i] = super.getListResult().get(i).get(Key.KEY_RANGQIU);
			spf[i] = super.getListResult().get(i).get(Key.KEY_SPF);
			peilv[i] = super.getListResult().get(i).get(Key.KEY_PEILV);
			isdanma[i] = super.getListResult().get(i).get(Key.KEY_ISDANMA);
		}
		FootballHemaiDetailInfo.getHemaiDetailInfo().setMatchdate(matchdate);
		FootballHemaiDetailInfo.getHemaiDetailInfo().setHomesxname(homesxname);
		FootballHemaiDetailInfo.getHemaiDetailInfo().setAwaysxname(awaysxname);
		FootballHemaiDetailInfo.getHemaiDetailInfo().setRangqiu(rangqiu);
		FootballHemaiDetailInfo.getHemaiDetailInfo().setSpf(spf);
		FootballHemaiDetailInfo.getHemaiDetailInfo().setPeilv(peilv);
		FootballHemaiDetailInfo.getHemaiDetailInfo().setIsdanma(isdanma);
	}

	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}

}
